Skip to content

Improve the error message when ACL is not attached - #158

Closed
bajtos wants to merge 1 commit into
masterfrom
feature/better-error-message-when-ACL-is-not-attached
Closed

bajtos wants to merge 1 commit into
masterfrom
feature/better-error-message-when-ACL-is-not-attached

Conversation

@bajtos

@bajtos bajtos commented Jan 28, 2014

Copy link
Copy Markdown
Member

Check whether the ACL model is attached to a datasource and report a helpful message if it is not.

One of the reasons why the ACL model may not be attached is that the user did not call loopback.autoAttach().

This is the original error message:

TypeError: Object function ModelConstructor(data, dataSource) {
  if (!(this instanceof ModelConstructor)) {
    return new ModelConstructor(data, dataSource);
  }
  if (ModelClass.settings.unresolved) {
    throw new Error('Model ' + ModelClass.modelName + ' is not defined.');
  }
  ModelBaseClass.apply(this, arguments);
  if (dataSource) {
    hiddenProperty(this, '__dataSource', dataSource);
  }
} has no method 'find'

/to: @raymondfeng or @ritch please review

Check whether the ACL model is attached to a datasource and report
a helpful message if it is not.

One of the reasons why the ACL model may not be attached is that
the user did not call `loopback.autoAttach()`.
@bajtos

bajtos commented Jan 28, 2014

Copy link
Copy Markdown
Member Author
  1. Add an optional 'dataSourceRequired' property to the model options so that the model itself can express the requirement to have a certain type of data source attached.
  2. Mix in stub CRUD methods that report errors by default.

Could you point me to the best place in loopback-datasource-juggler where to star looking? How am I going to determine which CRUD methods should be mixed in? (Is there a notion of datasource types, like database vs. email vs. rest connector?)

@raymondfeng

Copy link
Copy Markdown
Member

@ritch is implementing the behavior for models that are yet to be attached to a CRUD datasource: 9a2a422

@bajtos

bajtos commented Mar 26, 2014

Copy link
Copy Markdown
Member Author

Closing unmerged in favour of 9a2a422

@bajtos bajtos closed this Mar 26, 2014
@bajtos
bajtos deleted the feature/better-error-message-when-ACL-is-not-attached branch June 5, 2014 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants